<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<body>
    <h1>axios基础使用</h1>
    <button id="getBtn">get按钮</button>
    <button id="postBtn">post按钮</button>
    <button id="deleteBtn">delete按钮</button>
    <button id="inpBtn">inp按钮</button>
    <script>
        const getBtn = document.getElementById('getBtn')
        const postBtn = document.getElementById('postBtn')
        const deleteBtn = document.getElementById('deleteBtn')
        const inpBtn = document.getElementById('inpBtn')
        getBtn.onclick = async function () {
            const re = await axios.get('/user', { params: { userID: '001' } })
            console.log(re.data);
        }
        postBtn.onclick = async function () {
            const re = await axios.post('/adduser', { userID:'100',name: '星辰' })
            console.log(re.data);
        }
        deleteBtn.onclick = async function () {
            const re = await axios.delete('/deleteuser', { params: { userID: '001' } })
            console.log(re.data);
        }
        inpBtn.onclick = async function () {
            const re = await axios.put('/updateuser', {userID:'100',name:'星月'})
            console.log(re.data);
        }
    </script>
</body>

</html>